import { Cache } from "../../../cache/Cache";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { Language } from "../../../../../extend/language/Language";
import { CrossGuildWarStage } from "../data/CrossGuildWarStage";
type int = number;
//class CrossGuildWarUtil
    
    export  class CrossGuildWarUtil
    {
        

        public static isOurGuild(arg1: string, arg2: int): Boolean
        {
            if (arg1 != Cache.instance.guild.myGuildInfo.guildName) 
            {
                return false;
            }
            if (arg2 != Cache.instance.guild.myGuildInfo.guildId) 
            {
                return false;
            }
            return true;
        }

        public static isMyGuildInList(arg1: Array<any>): Boolean
        {
            var loc2=null;
            if (Cache.instance.guild.myGuildInfo == null || arg1 == null) 
            {
                return false;
            }
            var loc1=Cache.instance.guild.myGuildInfo.guildId;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                if (!EntityUtil.isSameServer(Cache.instance.role.entityInfo.entityId, loc2)) 
                {
                    continue;
                }
                if (loc1 != loc2.id) 
                {
                    continue;
                }
                return true;
            }
            return false;
        }

        public static getRankHtmlName(arg1: int): string
        {
            if (arg1 == 1) 
            {
                return Language.getString(80578);
            }
            if (arg1 == 2) 
            {
                return Language.getString(80579);
            }
            var loc1=Language.getStringByParam(80577, arg1.toString());
            var loc2="#9BEDE9";
            var loc3=arg1;
            switch (loc3) 
            {
                case 4:
                {
                    loc2 = "#F639D3";
                    break;
                }
                case 8:
                {
                    loc2 = "#38AFFF";
                    break;
                }
                case 16:
                {
                    loc2 = "#00FF00";
                    break;
                }
                case 32:
                {
                    loc2 = "#9BEDE9";
                    break;
                }
            }
            return "<font color = \'" + loc2 + "\'>" + loc1 + "</font>";
        }

        public static getRewardCode(arg1: int): int
        {
            var loc1=CrossGuildWarUtil.getLog2(arg1);
            if (loc1 < 0 || loc1 > CrossGuildWarUtil.rewards.length) 
            {
                loc1 = 5;
            }
            return int(CrossGuildWarUtil.rewards[loc1]);
        }

        public static getRewardHonor(arg1: int): int
        {
            var loc1=CrossGuildWarUtil.getLog2(arg1);
            if (loc1 < 0 || loc1 > CrossGuildWarUtil.honors.length) 
            {
                loc1 = 5;
            }
            return int(CrossGuildWarUtil.honors[loc1]);
        }

        public static getCompareCurRound(arg1: int, arg2: int): int
        {
            if (arg1 < 0) 
            {
                return 1;
            }
            var loc1=CrossGuildWarUtil.getCurRoundIndex(arg2);
            if (loc1 < 0) 
            {
                return 1;
            }
            if (arg1 == loc1) 
            {
                return 0;
            }
            if (arg1 < loc1) 
            {
                return -1;
            }
            return -1;
        }

        public static getCurRoundIndex(arg1: int): int
        {
            var loc1=-1;
            var loc2=arg1;
            switch (loc2) 
            {
                case CrossGuildWarStage.ChooseForTop16: case CrossGuildWarStage.FightForTop16:
                {
                    loc1 = 0;
                    break;
                }
                case CrossGuildWarStage.ChooseForTop8: case CrossGuildWarStage.FightForTop8:
                {
                    loc1 = 1;
                    break;
                }
                case CrossGuildWarStage.ChooseForTop4: case CrossGuildWarStage.FightForTop4:
                {
                    loc1 = 2;
                    break;
                }
                case CrossGuildWarStage.ChooseForTop2: case CrossGuildWarStage.FightForTop2:
                {
                    loc1 = 3;
                    break;
                }
                case CrossGuildWarStage.ChooseForTop1: case CrossGuildWarStage.FightForTop1:
                {
                    loc1 = 4;
                    break;
                }
            }
            return loc1;
        }

        /* internal  */static getLog2(arg1: int): int
        {
            var loc1=0;
            while (arg1 > 1) 
            {
                arg1 = arg1 >> 1;
                ++loc1;
            }
            return loc1;
        }

        public static /* var */rewards: Array<any>;

        public static /* var */honors: Array<any>;
    }

            CrossGuildWarUtil.rewards = Language.getString(80569).split(",");
            CrossGuildWarUtil.honors = Language.getString(80580).split(",");
        